import { rawRequestClient } from '#/api/request';

// 用户身份接口类型定义
export interface UserIdentity {
  id?: string;
  userId: string;
  providerId: number;
  providerUserId: string;
  lastUsedAt?: string;
  metadata?: string;
  createdAt?: string;
  createdBy?: string;
}

// 获取用户身份列表
export function getUserIdentityList(params?: {
  page?: number;
  size?: number;
  userId?: string;
  providerId?: number;
  providerUserId?: string;
}) {
  return rawRequestClient.get(`${import.meta.env.VITE_AUTH_SERVER}/user-identities`, { params });
}

// 创建用户身份
export function createUserIdentity(data: Omit<UserIdentity, 'id' | 'createdAt' | 'createdBy'>) {
  return rawRequestClient.post(`${import.meta.env.VITE_AUTH_SERVER}/user-identities`, data);
}

// 获取用户身份详情
export function getUserIdentityDetail(id: string) {
  return rawRequestClient.get(`${import.meta.env.VITE_AUTH_SERVER}/user-identities/${id}`);
}

// 更新用户身份
export function updateUserIdentity(id: string, data: Omit<UserIdentity, 'id' | 'createdAt' | 'createdBy'>) {
  return rawRequestClient.put(`${import.meta.env.VITE_AUTH_SERVER}/user-identities/${id}`, data);
}

// 删除用户身份
export function deleteUserIdentity(id: string) {
  return rawRequestClient.delete(`${import.meta.env.VITE_AUTH_SERVER}/user-identities/${id}`);
}
